package com.cgtong.android.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.blankj.utilcode.util.LogUtils;
import com.cgtong.android.R;
import com.cgtong.android.bean.UserBean;
import com.cgtong.android.util.CommonUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by chunc on 2017/10/19.
 */

public class UserFollowedAdapter extends BaseQuickAdapter<UserBean, BaseViewHolder> {
    public UserFollowedAdapter(@Nullable List<UserBean> data) {
        super(R.layout.adapter_followed_people, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, UserBean item) {

        ImageView avatarImg = helper.getView(R.id.avatar_img);
        if (item.getAvatarId() >= 1 && item.getAvatarId() <= 12) {
            CommonUtils.setUserAvatar(mContext, avatarImg, item.getAvatarId());
        } else {
            LogUtils.d("avatarId错误");
            avatarImg.setImageResource(R.drawable.head_1);
        }

        helper.setText(R.id.name_txt, item.getNickName());
//        String address = TextUtils.isEmpty(item.getAddress()) ? "" : item.getAddress();
        String sex = item.getSex() == 1 ? "男" : "女";
        helper.setText(R.id.personl_info_txt, sex);

        helper.addOnClickListener(R.id.cancel_follow_txt);

    }
}
